//
//  AboutLearnController.m
//  Learn
//
//  Created by zyl on 2024/4/2.
//  Copyright © 2024 迟建国. All rights reserved.
//

#import "AboutLearnController.h"
#import "VipCenterTableViewCell.h"
#import "MineAPIManager.h"
@interface AboutLearnController ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic ,strong)UITableView *tableView;

@property(nonatomic ,strong)UIView *tableHeaderView;

@property(nonatomic ,strong)UIView *tableFootorView;

@property(nonatomic ,strong)UIButton *shareBtn;

@property(nonatomic ,strong)NSDictionary *data;


@end

@implementation AboutLearnController
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self renderNavBarWithBackgroundImage:[UIImage imageWithColor:lWhiteColor] backgroundColor:lClearColor shadowColor:nil textAttributeDic:@{NSForegroundColorAttributeName:rgba(51, 51, 51, 1),NSFontAttributeName:MFontWithSize(18)} enableScrollEdgeAppearance:NO];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"关于学而时习";
    // Do any additional setup after loading the view.
    [self setBackButtonIsHidden:NO];
    [self.view addSubview:self.tableView];
    self.view.backgroundColor = rgba(255, 255, 255, 1);
    [MineAPIManager GetAboutMsgWithParam:@{} result:^(NSDictionary * _Nonnull dic) {
        self.data = dic;
    }];
}
- (void)shareBtnAction
{
    
}
#pragma mark -UITableViewDelegate,UITableViewDelegate
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = nil;
    
    if (!cell)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@""];
        cell.selectionStyle =UITableViewCellSelectionStyleNone;
    }
    [cell removeAllSubviews];
    UILabel *lab = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, lScreenWidth - 20, 13)];
    lab.text = self.data.allValues[indexPath.row];
    lab.textColor = rgba(51, 51, 51, 1);
    lab.textAlignment = NSTextAlignmentCenter;
    [cell addSubview:lab];
    return cell;
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.data.allValues.count;
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    return 13;
    
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    
}
#pragma mark -getters and setters
-(UITableView *)tableView{
    if (!_tableView){
        _tableView =[[UITableView alloc] initWithFrame:CGRectMake(0, lTopBarHeight, lScreenWidth, lScreenHeight - lTopBarHeight) style:UITableViewStylePlain];
        [_tableView setDelegate:self];
        [_tableView setDataSource:self];
        _tableView.bounces = NO;
        [_tableView setBackgroundColor:lClearColor];
        [_tableView setSeparatorColor:lClearColor];
        [_tableView setSeparatorInset:UIEdgeInsetsMake(0, 10, 0, 0)];
        [_tableView setTableHeaderView:self.tableHeaderView];
        [_tableView setTableFooterView:self.tableFootorView];
    }
    
    return _tableView;
}
-(UIView *)tableFootorView
{
    if (!_tableFootorView)
    {
        _tableFootorView =[[UIView alloc] initWithFrame:CGRectMake(0, 0, lScreenWidth, 146)];
        _tableFootorView.backgroundColor = lWhiteColor;
        UIView *btnView =[[UIView alloc] initWithFrame:CGRectMake((lScreenWidth - self.shareBtn.width)/2.0, 65, self.shareBtn.width, self.shareBtn.height)];
        [btnView setAllCornersWithCornerRadius:self.shareBtn.height/2.0];
        // gradient
        CAGradientLayer *gl = [CAGradientLayer layer];
        gl.frame = CGRectMake(0,0,btnView.width,btnView.height);
        gl.startPoint = CGPointMake(1, 0.5);
        gl.endPoint = CGPointMake(0, 0.5);
        gl.colors = @[(__bridge id)[UIColor colorWithRed:41/255.0 green:241/255.0 blue:156/255.0 alpha:1.0].CGColor, (__bridge id)[UIColor colorWithRed:2/255.0 green:161/255.0 blue:249/255.0 alpha:1.0].CGColor];
        gl.locations = @[@(0), @(1.0f)];
        [btnView.layer addSublayer:gl];
        [btnView addSubview:self.shareBtn];
        [_tableFootorView addSubview:btnView];
        [_tableFootorView setHeight:btnView.bottom];
    }
    
    return _tableFootorView;
    
}
-(UIView *)tableHeaderView
{
    if (!_tableHeaderView)
    {
        _tableHeaderView =[[UIView alloc] initWithFrame:CGRectMake(0, 0, lScreenWidth, 212)];
        _tableHeaderView.backgroundColor = lWhiteColor;
        
        UIImageView *lampView = [[UIImageView alloc] initWithFrame:CGRectMake((lScreenWidth - 120)/2.0, 30, 120, 120)];
        lampView.backgroundColor = lRedColor;
        [_tableHeaderView addSubview:lampView];
      
    }
    
    return _tableHeaderView;
    
}
-(UIButton *)shareBtn
{
    if (!_shareBtn)
    {
        _shareBtn = [UIButton new];
        _shareBtn.frame =CGRectMake(0, 0, 135, 40);
       
        _shareBtn.selected =NO;
        [_shareBtn setTitle:@"分享" forState:UIControlStateNormal];
        [_shareBtn setTitleColor:lWhiteColor forState:UIControlStateNormal];
        [_shareBtn.titleLabel setFont:MFontWithSize(18)];
        [_shareBtn addTarget:self action:@selector(shareBtnAction) forControlEvents:UIControlEventTouchUpInside];
        _shareBtn.backgroundColor = lClearColor;
       

    }
    
    return _shareBtn;
}

@end
